package mid;

import org.junit.Test;

public class a220_存在重复元素III {
    public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) {
        if (nums.length < 2) {
            return false;
        }
        for (int i = 0; i < nums.length - 1; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (Math.abs(j - i) <= k && Math.abs((long) nums[i] - (long) nums[j]) <= t) {
                    return true;
                }
            }
        }
        return false;
    }

    @Test
    public void test() {
        int[] nums = new int[]{-2147483648, 2147483647};
        System.out.println(containsNearbyAlmostDuplicate(nums, 1, 1));
    }
}
